﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UI.Panels.Providers;
using UI.Panels.Providers.DataProviders;
using StarPlatinum.EventManager;
using StarPlatinum;

namespace UI.Panels
{
	public partial class CommonSettingPanel : UIPanel<UIDataProvider, DataProvider>
	{
		#region UI template method
		public override void Initialize (UIDataProvider uiDataProvider, UIPanelSettings settings)
		{
			base.Initialize (uiDataProvider, settings);
			m_model.Initialize(this);
        }

		public override void DeInitialize()
		{
			m_model.Deactivate();
			base.DeInitialize();
		}

        public override void Hide()
        {
            m_model.Hide();
            base.Hide();
            EventManager.Instance.SendEvent(new SettingStateEvent() { IsShow = false });
        }

        public override void Deactivate()
		{
			m_model.Deactivate();
			base.Deactivate();
		}

		public override void ShowData(DataProvider data)
		{
			m_model.ShowData(data);
			base.ShowData(data);
		}

		public override void UpdateData(DataProvider data)
		{
			m_model.UpdateData(data);
			base.UpdateData(data);
		}

		public override void Tick()
		{
			m_model.Tick();
			base.Tick();
		}

		public override void LateTick()
		{
			m_model.LateTick();
			base.LateTick();
		}

		public override void SubpanelChanged(UIPanelType type, DataProvider data = null)
		{
			m_model.SubpanelChanged(type, data);
			base.SubpanelChanged(type, data);
		}

		public override void SubpanelDataChanged(UIPanelType type, DataProvider data)
		{
			m_model.SubpanelDataChanged(type, data);
			base.SubpanelDataChanged(type, data);
		}
		#endregion

		#region Member
        public void OnClickExitBtn()
        {
            Application.Quit();// 退出游戏
        }

        public void OnClickCloseBtn()
        {
            InvokeHidePanel();
        }

		#endregion
	}
}